﻿<html>
<!DOCTYPE html>
<html lang="en" class="no-js">

<head>

    <meta charset="utf-8">
    <title>注册</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

    <!-- CSS -->
    <link rel="stylesheet" href="../assets/css/reset.css">
    <link rel="stylesheet" href="../assets/css/supersized.css">
    <link rel="stylesheet" href="../assets/css/style.css">

    <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
    <script src="../assets/js/html5.js"></script>
    <![endif]-->

    <style type="text/css">
        #role {
            width: 350px;
            height: 42px;
            margin-top: 25px;
            padding: 0 15px;
            background: #2d2d2d; /* browsers that don't support rgba */
            background: rgba(45,45,45,.15);
            border-radius: 6px;
            border: 1px solid #3d3d3d; /* browsers that don't support rgba */
            border: 1px solid rgba(255,255,255,.15);
            box-shadow: 0 2px 3px 0 rgba(0,0,0,.1) inset;
            font-family: 'PT Sans', Helvetica, Arial, sans-serif;
            font-size: 14px;
            color: #fff;
            text-shadow: 0 1px 2px rgba(0,0,0,.1);
            -o-transition: all .2s;
            -moz-transition: all .2s;
            -webkit-transition: all .2s;
            -ms-transition: all .2s;
            -moz-border-radius: 6px;
            -webkit-border-radius: 6px;
            -moz-box-shadow: 0 2px 3px 0 rgba(0,0,0,.1) inset;
            -webkit-box-shadow: 0 2px 3px 0 rgba(0,0,0,.1) inset;
        }

    </style>

</head>

<body>

<div class="page-container">
    <h1>用户注册</h1>
    <br>
    <br>
    <form action="javascript:;" method="post">
        <input type="text" id="username" name="username" class="username" placeholder="请输入您的用户名！">
        <input type="password" id="password" name="password" class="password" placeholder="请输入您的用户密码！">
        <select id="role" name="role">
            <option value="">请选择角色</option>
            <option value="1">租户</option>
            <option value="2">房东</option>
        </select>
        <button type="submit" class="submit_button">注册</button>
    </form>
</div>

<!-- Javascript -->
<script src="../assets/js/jquery-1.8.2.min.js"></script>
<script src="../assets/js/supersized.3.2.7.min.js"></script>
<script src="../assets/js/supersized-init.js"></script>
<script src="../assets/js/scripts.js"></script>
<script type="text/javascript">
    $(function () {
        $(":submit").on("click", function () {
            var hm = $("#username").val();
            var pwd = $("#password").val();
            var role = $("#role").val();
            if (hm == "") {
                alert("用户名不能为空！")
                return;
            }
            if (pwd == "") {
                alert("用户密码不能为空！")
                return;
            }
            if (role == "") {
                alert("角色不能为空！")
                return;
            }
            $.ajax({
                url: "register",
                type: "post",
                data: JSON.stringify({
                    hm: hm,
                    pwd: pwd,
                    role: role
                }),
                dataType: "json",
                success: function (data) {
                    if (data.result == 2) {
                        alert("注册失败!");
                    } else if(data.result == 3){
                        alert("用户名已存在")
                    } else{
                        window.location.href = "/index"
                    }
                }
            })
        });
    });
</script>
</body>

</html>

